const http = require('http')

const server = http.createServer()

server.listen(3030,()=>{
  console.log('服务器启动成功');
})

server.on('request',(req,res)=>{
  res.setHeader('Content-Type', 'text/html; charset=utf-8');
  // 设置响应状态码
  res.statusCode = 200;
  if (req.url === '/' || req.url === 'index.html') {
    res.end('<h1>这是首页</h1>');
  } else if (req.url === '/login.html') {
    res.end('<h1>这是登录页</h1>');
  } else {
    res.end('<h1>404你访问的页面走丢了</h1>');
    res.statusCode = 404
  }
})